<?php
/**
 * controller_base 控制器基类(抽象)
 */
abstract class controller_base extends common_controller {
	private $run_time_start;
	
	/**
	 * before
	 */
	public function before() {
		$model_auth = new model_auth();
        
        $noauth = preg_split('/\s+/', trim(Config::get('NOAUTH_ALOW_URI')));

		//访问条件验证
		if($model_auth->access() || in_array(MODULE.'/'.ACTION, $noauth) || in_array(MODULE.'/*', $noauth) || in_array($_SERVER['QUERY_STRING'], $noauth)) {
			//允许访问, 添加点击次数
			new model_app_hits();
		} else {
			//禁止访问, 跳转并中止程序
			$url_current = base64_encode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
			echo '<script>parent.location.href="?m=auth&a=login&referer='.$url_current.'"</script>';
			exit();
		}
	}
	
	/**
	 * after
	 */
	public function after() {

	}
}
